public class Test {
    public static void main(String[] args) {
        Solution s = new Solution();
        int[] nums = {11,13,15,17};
        int ret = s.findMin(nums);
        System.out.println(ret);
    }
}


class Solution {

    //方法二：采用最左边作为边界划分
    public int findMin(int[] nums) {
        int left = 0;
        int right = nums.length - 1;
        int middle = nums[0];
        if (nums[0] < nums[right]) {
            return nums[0];
        }

        while (left < right) {
            int mid = left + (right - left) / 2;//先放着
            if (nums[mid] < middle) {
                right = mid;
            }else{
                left = mid + 1;
            }
        }
        return nums[left];
    }

    //方法一：采用最右边作为边界划分
    public int findMin1(int[] nums) {
        //
        int left = 0;
        int right = nums.length - 1;
        int middle = nums[nums.length - 1];
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (nums[mid] < middle) {
                right = mid ;
            }else{
                left = mid + 1;
            }
        }
        return nums[right];
    }
}